%global gmp_version 6.1.2
%global mpfr_version 4.1.0
%global mpc_version 1.2.1
%global isl_version 0.24
#%global DATE 20220409
#%global gcc_version 11.2.1
%global gcc_version 11.3.0-RC-20220414

Name:		gcc
Version:	11.2.1
Release:	1%{?dist}
Summary:	GNU compiler collection
Provides: cpp = %{version}-%{release}

License:	GPLv3+
URL:		https://gcc.gnu.org
Source0: https://gcc.gnu.org/pub/gcc/snapshots/11.3.0-RC-20220414/gcc-11.3.0-RC-20220414.tar.xz
Source1: https://gmplib.org/download/gmp/gmp-%{gmp_version}.tar.lz
Source2: https://ftp.gnu.org/gnu/mpfr/mpfr-%{mpfr_version}.tar.xz
Source3: https://ftp.gnu.org/gnu/mpc/mpc-%{mpc_version}.tar.gz
Source4: https://gcc.gnu.org/pub/gcc/infrastructure/isl-%{isl_version}.tar.bz2

BuildRequires:	gcc-c++ gcc-gnat lzip texinfo

%description
GNU compiler collection

%package -n libgcc
Summary: GCC version 11 shared support library
Autoreq: false
Provides: libatomic = %{version}-%{release}
Provides: libatomic-static = %{version}-%{release}
Provides: libgomp = %{version}-%{release}
Provides: libgomp-static = %{version}-%{release}
Provides: libquadmath = %{version}-%{release}
Provides: libquadmath-static = %{version}-%{release}
Provides: libitm = %{version}-%{release}
Provides: libitm-static = %{version}-%{release}
Provides: libasan= %{version}-%{release}
Provides: libasan-static = %{version}-%{release}
Provides: libubsan= %{version}-%{release}
Provides: libubsan-static = %{version}-%{release}
Provides: libtsan= %{version}-%{release}
Provides: libtsan-static = %{version}-%{release}

%description -n libgcc
This package contains GCC shared support library which is needed
e.g. for exception handling support.


%package c++
Summary: C++ support for GCC  version 11
Requires: gcc = %{version}-%{release}
Requires: libstdc++ = %{version}-%{release}
Autoreq: true

%description c++
This package adds C++ support to the GNU Compiler Collection
version 11.  It includes support for most of the current C++ specification
and a lot of support for the upcoming C++ specification.

%package -n libstdc++
Summary: GNU Standard C++ Library
Autoreq: true
Requires: glibc >= 2.10.90-7
Provides: libstdc++-devel = %{version}-%{release}

%description -n libstdc++
The libstdc++ package contains a rewritten standard compliant GCC Standard
C++ Library.

%package gnat
Summary: GCC Ada
Requires: gcc = %{version}-%{release}

%description gnat
GCC Ada frontend


%prep
%setup -q -n gcc-%{gcc_version} -a 1 -a 2 -a 3 -a 4
mv gmp-%{gmp_version} gmp
mv mpfr-%{mpfr_version} mpfr
mv mpc-%{mpc_version} mpc
mv isl-%{isl_version} isl

#  --with-build-config=bootstrap-lto \
%build
mkdir build-gcc
cd build-gcc
../configure --prefix=%{_prefix} --libdir=%{_libdir} \
  --disable-multilib \
  --enable-bootstrap \
  --with-linker-hash-style=gnu \
  --enable-languages=c,c++,ada,lto \
  --enable-lto \
  --enable-plugin \
  --enable-shared \
  --enable-threads=posix \
  --enable-__cxa_atexit \
  --enable-cet=auto \
  --enable-clocale=gnu \
  --enable-gnu-indirect-function \
  --enable-gnu-unique-object \
  --enable-linker-build-id \
  --disable-libssp \
  --disable-libstdcxx-pch \
  --disable-werror \
  --enable-link-serialization=1
make %{?_smp_mflags}


%install
cd build-gcc
make DESTDIR=%{buildroot} install
rm -f %{buildroot}/%{_infodir}/dir
rm -rf %{buildroot}/%{_mandir}/man7
find %{buildroot} -name '*.la' -delete
ln -sf gcc %{buildroot}%{_prefix}/bin/cc
mv %{buildroot}%{_libdir}/libgcc_s.so.1 %{buildroot}%{_libdir}/libgcc_s-%{version}-%{DATE}.so.1
chmod 755 %{buildroot}%{_libdir}/libgcc_s-%{version}-%{DATE}.so.1
ln -sf libgcc_s-%{version}-%{DATE}.so.1 %{buildroot}%{_libdir}/libgcc_s.so.1

cat > %{buildroot}%{_prefix}/bin/c89 <<"EOF"
#!/bin/sh
fl="-std=c89"
for opt; do
  case "$opt" in
    -ansi|-std=c89|-std=iso9899:1990) fl="";;
    -std=*) echo "`basename $0` called with non ANSI/ISO C option $opt" >&2
	    exit 1;;
  esac
done
exec gcc $fl ${1+"$@"}
EOF
cat > %{buildroot}%{_prefix}/bin/c99 <<"EOF"
#!/bin/sh
fl="-std=c99"
for opt; do
  case "$opt" in
    -std=c99|-std=iso9899:1999) fl="";;
    -std=*) echo "`basename $0` called with non ISO C99 option $opt" >&2
	    exit 1;;
  esac
done
exec gcc $fl ${1+"$@"}
EOF
chmod 755 %{buildroot}%{_prefix}/bin/c89
chmod 755 %{buildroot}%{_prefix}/bin/c99

%files
/usr/bin/gcc
/usr/bin/cc
/usr/bin/c89
/usr/bin/c99
/usr/bin/lto-dump
/usr/bin/gcc-ar
/usr/bin/gcc-nm
/usr/bin/gcov
/usr/bin/x86_64-pc-linux-gnu-gcc
/usr/bin/cpp
/usr/bin/gcc-ranlib
/usr/bin/x86_64-pc-linux-gnu-gcc-ranlib
/usr/bin/x86_64-pc-linux-gnu-gcc-nm
/usr/bin/gcov-dump
/usr/bin/x86_64-pc-linux-gnu-gcc-11.2.1
/usr/bin/gcov-tool
/usr/bin/x86_64-pc-linux-gnu-gcc-ar
/usr/share/gcc-11.2.1/python/libstdcxx
%{_infodir}/gcc.*
%{_infodir}/cppinternals.*
%{_infodir}/gccint.*
%{_infodir}/cpp.*
%{_infodir}/gccinstall.*
/usr/share/locale/*/LC_MESSAGES/gcc.mo
/usr/share/locale/*/LC_MESSAGES/cpplib.mo
/usr/share/man/man1/lto-dump.*
/usr/share/man/man1/gcov-dump.*
/usr/share/man/man1/gcc.*
/usr/share/man/man1/gcov.*
/usr/share/man/man1/cpp.*
/usr/share/man/man1/gcov-tool.*
%{_libdir}/libcc1.*
%{_libdir}/gcc/x86_64-pc-linux-gnu/11.2.1/crt*.o
%{_libdir}/gcc/x86_64-pc-linux-gnu/11.2.1/libgcov.a
%{_libdir}/gcc/x86_64-pc-linux-gnu/11.2.1/libgcc.a
%{_libdir}/gcc/x86_64-pc-linux-gnu/11.2.1/libgcc_eh.a
%{_libdir}/gcc/x86_64-pc-linux-gnu/11.2.1/install-tools
%{_libdir}/gcc/x86_64-pc-linux-gnu/11.2.1/plugin
%{_libdir}/gcc/x86_64-pc-linux-gnu/11.2.1/include-fixed
%{_libdir}/gcc/x86_64-pc-linux-gnu/11.2.1/include
%{_libdir}/libsanitizer.spec
/usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.1/lto-wrapper
/usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.1/install-tools
/usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.1/plugin
/usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.1/lto1
/usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.1/liblto_plugin.so
/usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.1/collect2
/usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.1/cc1

%files -n libgcc
%{_libdir}/lib*san*
%{_libdir}/libquadmath*
%{_libdir}/libgomp*
%{_libdir}/libitm*
%{_libdir}/libatomic*
%{_libdir}/libgcc*
%{_infodir}/libquadmath.info*
%{_infodir}/libgomp.info*
%{_infodir}/libitm.info*

%post -n libgcc
/sbin/ldconfig
/sbin/install-info --info-dir=%{_infodir} %{_infodir}/libquadmath.info.gz
/sbin/install-info --info-dir=%{_infodir} %{_infodir}/libgomp.info.gz
/sbin/install-info --info-dir=%{_infodir} %{_infodir}/libitm.info.gz

%postun -n libgcc
/sbin/ldconfig
/sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/libquadmath.info.gz
/sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/libgomp.info.gz
/sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/libitm.info.gz

%files c++
/usr/bin/g++
/usr/bin/c++
/usr/bin/x86_64-pc-linux-gnu-g++
/usr/bin/x86_64-pc-linux-gnu-c++
/usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.1/g++-mapper-server
/usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.1/cc1plus
%{_includedir}/c++
%{_mandir}/man1/g++.*

%files -n libstdc++
%{_libdir}/libstdc++*
%{_libdir}/libsupc++*
/usr/share/locale/*/LC_MESSAGES/libstdc++.mo

%post -n libstdc++
/sbin/ldconfig

%postun -n libstdc++
/sbin/ldconfig

%files gnat
/usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.1/gnat1
/usr/bin/gnatclean
/usr/bin/gnatchop
/usr/bin/gnatfind
/usr/bin/gnatls
/usr/bin/gnatname
/usr/bin/gnatbind
/usr/bin/gnatkr
/usr/bin/gnat
/usr/bin/gnatmake
/usr/bin/gnatxref
/usr/bin/gnatlink
/usr/bin/gnatprep
%{_libdir}/gcc/x86_64-pc-linux-gnu/11.2.1/adalib
%{_libdir}/gcc/x86_64-pc-linux-gnu/11.2.1/adainclude
%{_libdir}/gcc/x86_64-pc-linux-gnu/11.2.1/ada_target_properties
%{_infodir}/gnat-style.*
%{_infodir}/gnat_ugn.*
%{_infodir}/gnat_rm.*

%post gnat
/sbin/ldconfig
/sbin/install-info --info-dir=%{_infodir} %{_infodir}/gnat-style.info.gz
/sbin/install-info --info-dir=%{_infodir} %{_infodir}/gnat_ugn.info.gz
/sbin/install-info --info-dir=%{_infodir} %{_infodir}/gnat_rm.info.gz

%postun gnat
/sbin/ldconfig
/sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/gnat-style.info.gz
/sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/gnat_ugn.info.gz
/sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/gnat_rm.info.gz

%changelog

